package com.zzyl.mapper;

import com.zzyl.entity.Role;
import com.zzyl.entity.UserRole;
import com.zzyl.vo.UserPageRoleVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserRoleMapper {

    int deleteByPrimaryKey(Long id);

    int insert(UserRole record);

    int insertSelective(UserRole record);

    UserRole selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserRole record);

    int updateByPrimaryKey(UserRole record);

    int batchInsert(@Param("list") List<UserRole> list);

    //查询角色是否绑定用户
    Long selectUserByRole(Role role);




    //【查询用户绑定的角色】通过分页查到的用户ID，关联到user_role表，再关联role表，拿到role_id、role_name
    List<Long> selectByUserIdToRoleId(Long id);
    List<String> selectByUserIdToRoleName(Long id);

    //新增用户，绑定角色
    void insertByRoleVoIds(List<Long> roleVoIds);

    //删除所有绑定角色
    @Delete("delete from sys_user_role where user_id=#{id}")
    void deleteAll(Long id);
}